function checkEmail() {
    var flag = true;
    var email = document.getElementById("login-email").value;
    if (email == null || email == "") {
        flag = false;
        $("#msg").html("邮箱不能为空")
        $("#msg").show();
    }
    return flag;
}

function checkPasswd() {
    var flag = true;
    var passwd = document.getElementById("login-password").value;
    if (passwd == null || passwd == "") {
        flag = false;
        $("#msg").html("密码不能为空")
        $("#msg").show();
    }
    return flag;
}

function doLogin() {
    if (checkEmail() && checkPasswd()) {
        //选中记住我
        var check = 0;
        if($("#login-remember").attr("checked")){
            check = $("#login-remember").val();
        }
        $.ajax({
            url: "/Origami/checkLogin",
            type: "post",
            data: {email: $("#login-email").val(),passwd: $("#login-password").val(),checked: check },
            dataType: "json",
            async: false,
            complete: function (data) {
                if (data.responseText == 'fail') {
                    $("#msg").html("用户名或密码错误")
                } else if (data.responseText == 'succ') {
                    window.location.href = "/Origami/index";
                } else {
                    $('#msg').html("系统出现错误请稍后再试");
                }
            }
        })
    }
}